<?php
MYTCONN();
?><table width="98%"  border="0" cellspacing="1" cellpadding="4">
  <tr bgcolor="#CCCCCC">
    <td height="25" colspan="3">Documentos agregados</td>
    <td height="25" colspan="2"><label>
      <input type="submit" name="button" id="button" value="Guardar no disco">

      <input type="submit" name="button2" id="button2" value="Imprimir">
</label></td>
  </tr>
  <tr bgcolor="#CCCCCC">
    <td>Alerta</td>
    <td>ID do Documento </td>
    <td>Tipo de Documento</td>
    <td>Data</td>
    <td><input name="input" type="checkbox" value=""></td>
  </tr>
  <?php
  $Qr_rsDoc = $GLOBALS['MYT']->db_array("SELECT
  dtd_ID AS O_ID, dtd_Fecha AS COL1, tdc_Tipo AS COL4, DC_OFFICE AS COL2, FILE AS COL3, dtd_Status AS COL5, dtd_Numero AS COL6, 'T1' AS COL7,'' AS COL8
  FROM hd_documentos
  INNER JOIN hd_documentostipos ON dtd_Tipo = tdc_Id
   WHERE dtd_Cliente = {$_POST['CliNumero']}
 UNION
 	SELECT
  dnl_ID AS O_ID, dnl_FechaEntrega AS COL1, dnc_Doc AS COL4, dnl_OFFICE COL2, dnl_FILE AS COL3, dnl_Activo AS COL5, dnl_Observ AS COL6, 'T2' AS COL7, dnl_AML AS COL8
  FROM hd_docdocumentos
  INNER JOIN hd_doctipos ON dnl_TipoDoc = dnc_ID
   WHERE dnl_CL = {$_POST['CliNumero']}");
	$CARD1 = $Qr_rsDoc[0];
	for ($r = 1; $r<=$CARD1; $r++) { ?>
  <tr bgcolor="<?php echo gridlines($r);?>">
	<td><?php echo $Qr_rsDoc[$r]['COL8'];?></td>
    <td><?php
	if ($Qr_rsDoc[$r]['COL3'] != '') {
		echo '<a href="javascript:modalwindow(\'Pre-visualizacao\',\'_response/call.php?get=Compliance/amh_docview&ID='.$Qr_rsDoc[$r]['O_ID'].'&RSID='.$Qr_rsDoc[$r]['COL3'].'&RSIF='.$_POST['CliNumero'].'\',905,500);">'.$Qr_rsDoc[$r]['O_ID'].'</a>';
	} else {
		echo $Qr_rsDoc[$r]['O_ID'];
	} ?></td>
    <td><?php echo $Qr_rsDoc[$r]['COL4'];?></td>
    <td><?php echo $Qr_rsDoc[$r]['COL1'];?></td>
    <td><?php
		if($Qr_rsDoc[$r]['COL3'] == '') {
		echo '';
		} else {
		mn_field('checkbox','ED','doc_select','','','','','');
		}?></td>
    <td>
	<?php if ($Qr_rsDoc[$r]['COL7'] == 'T2') { ?>
	<div id="doc_<?php echo $Qr_rsDoc[$r]['O_ID'];?>"><?php mn_field('button','ED','doc_delete','Apagar','','','','SUBMIT" onclick="
	if(confirm(\'Tem a certeza que pretende apagar o `'.$Qr_rsDoc[$r]['COL4'].'` com o numero '.$Qr_rsDoc[$r]['O_ID'].' de '.$Qr_rsDoc[$r]['COL1'].'?\')==true) {
	replaceUrl(\'doc_'.$Qr_rsDoc[$r]['O_ID'].'\',\'_response/call.php?get=Compliance/doc_pract1?AMHDOC_ID='.$Qr_rsDoc[$r]['O_ID'].'\');
	}'); ?></div><?php } ?></td>
  </tr>
  <?php } ?>
</table>
